﻿
//Author: 张亚涛
//createtime:2015-12-24 18:32:49
//Description: 

using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Model;
using DAL;

namespace BLL
{
    /// <summary>
    /// 该类提供了一系列操作 "Coupons" 表的方法;
    /// </summary>
    public class CouponsService
    {
        #region .对本表的维护.
        #region select data
        /// <summary>
        /// 返回Coupons表的所有数据  
        /// </summary>
        /// <param name="OpenID">微信ID</param>
        /// <param name="IsUsable">可用标识</param>
        /// <param name="couType">类型</param>
        /// <param name="order">排序</param>
        /// <returns></returns>        
        public static List<Coupons> GetAllCoupons(string OpenID, int IsUsable, int couType, string order)
        {
            return CouponsBase.GetAllCoupons(OpenID, IsUsable, couType, order);
        }
        /// <summary>
        /// 根据Coupons表的ID字段返回数据  
        /// </summary>
        /// <param name="id">ID</param>
        /// <returns></returns>        
        public static Coupons GetCouponsById(long id)
        {
            return CouponsBase.GetCouponsById(id);
        }
        /// <summary>
        /// 是否已使用
        /// </summary>
        /// <param name="ID">ID</param>
        /// <returns></returns>        
        public static bool IsUse(int ID)
        {
            return CouponsBase.IsUse(ID);
        }
        /// <summary>
        /// 是否首次优惠
        /// </summary>
        /// <param name="OpenID">微信ID</param>
        /// <returns></returns>        
        public static bool IsFirst(string OpenID)
        {
            return CouponsBase.IsFirst(OpenID);
        }
        /// <summary>
        /// 返回优惠券可用数量
        /// </summary>
        /// <param name="openID">微信ID</param>
        /// <param name="couType">类型(0：优惠券1：洗车券)</param>
        /// <returns></returns>        
        public static int GetCount(string openID, int couType)
        {
            return CouponsBase.GetCount(openID, couType);
        }
        #endregion
        #region delete data
        /// <summary>
        /// 根据Coupons表的ID字段删除数据 
        /// </summary>
        /// <param name="id">id</param>
        /// <returns>返回受影响的行数</returns>
        public static int DeleteCouponsById(long id)
        {
            return CouponsBase.DeleteCouponsById(id);
        }
        #endregion
        #region update data
        /// <summary>
        /// 根据Coupons表的ID字段更新数据 
        /// </summary>
        /// <param name="id">Id</param>
        /// <param name="Coupons">coupons</param>
        /// <returns>返回受影响的行数</returns>
        public static int UpdateCouponsById(Coupons coupons)
        {
            return CouponsBase.UpdateCouponsById(coupons);
        }
        #endregion
        #region insert data
        /// <summary>
        /// 向Coupons表插入一条数据，插入成功则返回自增列数值，插入不成功则返回-1 
        /// </summary>
        /// <param name="coupons">Coupons</param>        
        /// <returns></returns>
        public static int AddCoupons(Coupons coupons)
        {
            return CouponsBase.AddCoupons(coupons);
        }
        #endregion
        #endregion

        #region .SQL语句汇总.
        /// <summary>
        /// 向Coupons表插入一条数据（SQL语句）
        /// </summary>
        /// <param name="m">Coupons</param>       
        /// <returns></returns>        
        public static string AddCoupons_SQL(Coupons m)
        {
            return CouponsBase.AddCoupons_SQL(m);
        }
        /// <summary>
        /// 更新使用状态（SQL语句）
        /// </summary> 
        /// <param name="couponsID">CouponsID</param>
        /// <param name="isUse">是否使用</param>
        /// <returns></returns>       
        public static string UpdateUse_SQL(long couponsID, int isUse)
        {
            return CouponsBase.UpdateUse_SQL(couponsID, isUse);
        }
        /// <summary>
        /// 返回Coupons表的所有数据（SQL语句） 
        /// </summary>
        /// <returns></returns>        
        public static string GetAllCoupons_SQL()
        {
            return CouponsBase.GetAllCoupons_SQL();
        }
        #endregion
    }
}